<?php
date_default_timezone_set('Asia/Shanghai');
use Workerman\Worker;
require_once __DIR__ . '/Autoloader.php';
require_once __DIR__ . '/vendor/autoload.php';
$worker = new Worker('tcp://0.0.0.0:777');
Worker::$stdoutFile = 'time.log';
$worker->count = 1;
$worker->onWorkerStart = function($data){
    echo "conn start\n";
};
$worker->onConnect = function($data){
    echo "conn finsh\n";
};
$worker->onMessage = function($con,$data) use ($worker){
    echo "get message{$data}\n";
        foreach($worker->connections as $id=>$connection){
            // 向客户端发送16进制数据
            $connection->send(hex2bin($data));
        }

};
$worker->onClose = function($data){
    echo "close conn\n";
};
$worker->onError = function($data){
    echo "err\n";
};
Worker::runAll();

